#ifndef SLAVETASKRETURNONE
#define SLAVETASKRETURNONE

#include <AbstractGridSlaveTask.h>
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>

using namespace MasterWorkerFramework;

class GridSlaveTaskReturnOne : public AbstractGridSlaveTask,public boost::enable_shared_from_this<GridSlaveTaskReturnOne>
{

public:
	GridSlaveTaskReturnOne (char* name)
		:AbstractGridSlaveTask(name){

			slave_task_name_= new std::string("GridSlaveTaskReturnOne");
	}


	std::string* GetSlaveTaskName()
	{
		return slave_task_name_;
	}

	VALUE_TYPE GetTaskType()
	{
		return VALUE_TYPE::VALUE_TYPE_INT32;
	}

	void Execute()
	{
		int*ptr;
		int value =1;

		for (std::vector<TaskResult*>::iterator vi = bindedResults_->begin(); vi != bindedResults_->end(); vi++)
			{
				if ((*vi)->GetType()==VALUE_TYPE::VALUE_TYPE_FLOAT)
				{
					value+= *((*vi)->GetResult<float>());
				}

				else if ((*vi)->GetType()==VALUE_TYPE::VALUE_TYPE_INT32)
				{
					value+= *((*vi)->GetResult<int>());
				}
			}

		result_ = new TaskResult(VALUE_TYPE::VALUE_TYPE_INT32);
		ptr= new int(value);
		result_->SetResult<int>(ptr);
		Sleep(2000);
	}

	~GridSlaveTaskReturnOne()
	{
		delete slave_task_name_;
	}

private:
	std::string* slave_task_name_;

};

#endif